﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Laugh.Data;
using Laugh.Example.Domain;
using Laugh.Example.Services;

namespace Laugh.Example.Controllers
{
    public class HomeController : BaseController
    {
        private IReportService _report;

        public HomeController(IReportService report)
        {
            _report = report;

            IReportService report2 = Resolver.GetService<IReportService>();
            var p1 = report2.UserPerson(1);

            string str = null;
            foreach (var i in p1)
            {
                str += i.Key.Name + ",";
            }

            ViewData.Add("name", str);
        }

        public ActionResult Index()
        {
            return View();
        }

        public ContentResult Index2(Person person)
        {
            person.Id = 1;
            person.Name = person.Name;
            person.Age = 2009;
            person.IdentityNo = "123";
            person.TelePhone = "asfd";

            _report.Update(person);
            return Content("<script>alert('修改成功');window.location.href='/Home/Index';</script>");
        }
    }
}